package utils

import (
	"crypto/rand"
	"encoding/hex"
	"fmt"
	"time"
)

// GenerateID 生成唯一ID
func GenerateID() string {
	timestamp := time.Now().UnixNano()
	randomBytes := make([]byte, 4)
	rand.Read(randomBytes)
	return fmt.Sprintf("%d-%s", timestamp, hex.EncodeToString(randomBytes))
}

// GenerateShortID 生成短ID（8位）
func GenerateShortID() string {
	randomBytes := make([]byte, 4)
	rand.Read(randomBytes)
	return hex.EncodeToString(randomBytes)
}

// GenerateTransactionID 生成事务ID
func GenerateTransactionID() string {
	return "tx-" + GenerateShortID()
}

// GenerateRequestID 生成请求ID
func GenerateRequestID() string {
	return "req-" + GenerateShortID()
}

// GenerateResponseID 生成响应ID
func GenerateResponseID() string {
	return "resp-" + GenerateShortID()
} 